﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 第四章
{
    public partial class _4__3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindTecher();

            }
        }
        /// <summary>
        /// 绑定老师
        /// </summary>
        private void BindTecher()
        {
            DrDoTeacher.Items.Clear();
            string institute = DrDoInstitute.SelectedValue;
            switch (institute)
            {
                case "计算机与信息工程学院":
                    for (int i = 0; i < 5; i++)
                    {
                        DrDoTeacher.Items.Add("计信老师" + i);
                    }
                    break;
                case "数学与统计学院":
                    for (int i = 0; i < 5; i++)
                    {
                        DrDoTeacher.Items.Add("数统老师" + i);
                    }
                    break;
                case "机械工程学院":
                    for (int i = 0; i < 5; i++)
                    {
                        DrDoTeacher.Items.Add("机械老师" + i);
                    }
                    break;
                case "土木工程与建筑学院":
                    for (int i = 0; i < 5; i++)
                    {
                        DrDoTeacher.Items.Add("土建老师" + i);
                    }
                    break;
                case "文学院":
                    for (int i = 0; i < 5; i++)
                    {
                        DrDoTeacher.Items.Add("语文老师" + i);
                    }
                    break;
            }

        }
        protected void DrDoInstitute_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindTecher();
        }

        protected void DrDoTeacher_SelectedIndexChanged(object sender, EventArgs e)
        {
            TableRow row = new TableRow();
            TableCell CellAcademicYear = new TableCell();
            TableCell CellTrem = new TableCell();
            TableCell CellInstitute = new TableCell();
            TableCell CellTeacher = new TableCell();

            string academicYear = DrDoAcaYear.SelectedValue;
            string trem = DrDoTerm.SelectedValue;
            string institute = DrDoInstitute.SelectedValue;
            string teacher = DrDoTeacher.SelectedValue;

            CellAcademicYear.Text = academicYear;
            CellTrem.Text = trem;
            CellInstitute.Text = institute;
            CellTeacher.Text = teacher;

            row.Cells.Add(CellAcademicYear);
            row.Cells.Add(CellTrem);
            row.Cells.Add(CellInstitute);
            row.Cells.Add(CellTeacher);

            TableInfo.Rows.Add(row);
        }
    }
}